package com.youxin.cpcenter.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.youxin.busfoundation.bean.ResponseObject;
import com.youxin.busfoundation.bean.orderinfo.ResponseOrderinfoBean;
import com.youxin.cpcenter.bean.ConsumQueryListBean;
import com.youxin.cpcenter.bean.RequestEntConsumeBean;
import com.youxin.cpcenter.common.log.LogMethod;
import com.youxin.cpcenter.model.TbEntConsume;
import com.youxin.cpcenter.service.EntConsumeService;
import com.youxin.cpcenter.service.OrderInfoService;


/**
 * 
 * @ClassName: ConsumingRecordsController 
 * @Description: 消费充值记录接口 
 * @author yingde.cao
 * @date 2017年12月5日 上午11:28:01 
 *
 */
@RestController
public class ConsumingRecordsController extends BaseController{
	
	@Autowired
	private OrderInfoService orderInfoService;	
	@Autowired
	private EntConsumeService entConsumeService;
	/**
	 * @Title: listConsum 
	 * @Description: 金券消费列表接口
	 * @param @param httpServletRequest
	 * @param @param httpServletResponse
	 * @param @param bean
	 * @param @return
	 * @return ResponseObject
	 * @throws
	 */
	@LogMethod(id="order.coupon.consum.list.",eventContent={"log.staytime"})
	@RequestMapping(value = "/api/coupon/consumlist", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseObject listCouponConsum(HttpServletRequest httpServletRequest, 
			HttpServletResponse httpServletResponse,@RequestBody RequestEntConsumeBean bean) {		
		try {			
			List<TbEntConsume> rs = entConsumeService.selectByPrimaryKey(bean);
			if(rs==null)
			{
				return ResponseObject.userFailure("展示列表失败");
			}
			return ResponseObject.successObject(bean);
		} catch (Exception e) {
			logger.error("/api/coupon/consumlist系统错误:", e);
			return ResponseObject.systemError(e);
		}
	}
	/**
	 * @Title: listPayConsum 
	 * @Description: 支付充值消费列表接口
	 * @param @param httpServletRequest
	 * @param @param httpServletResponse
	 * @param @param bean
	 * @param @return
	 * @return ResponseObject
	 * @throws
	 */
	@LogMethod(id="order.pay.consum.list.",eventContent={"log.staytime"})
	@RequestMapping(value = "/api/pay/consumlist", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseObject listPayConsum(HttpServletRequest httpServletRequest, 
			HttpServletResponse httpServletResponse, @RequestBody ConsumQueryListBean bean) {		
		try {			
			List<ResponseOrderinfoBean> tbOrderInfo=orderInfoService.payConsumList(bean);
			if(tbOrderInfo==null)
			{
				return ResponseObject.userFailure("展示列表失败");
			}
			return ResponseObject.successObject(bean);
		} catch (Exception e) {
			logger.error("/api/consum/list系统错误:", e);
			return ResponseObject.systemError(e);
		}
	}
}
